﻿-- ===============================================================================================
-- Basic View for LocationCountries
-- ===============================================================================================

IF  EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[esf_sso].[VLocationDeptosByCountry]'))
	DROP VIEW [esf_sso].[VLocationDeptosByCountry]
GO

-- SELECT * FROM [esf_sso].[VLocationDeptosByCountry]

CREATE VIEW [esf_sso].[VLocationDeptosByCountry] AS
	
	SELECT VBR.*, L.CountryID FROM esf_sso.VBasicReference VBR 
	INNER JOIN esf_sso.Location L ON L.DeptoID = VBR.ID
	WHERE BasicReferenceTypeID = 9
	
GO 